package com.qitmiaojie.controller.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    protected Integer StateCode;//状态码,50代表查询没有结果||用户名不存在，51代表用户密码错误，52代表操作失败
    protected String Msg;//信息
    protected Object object;
    public static <T> Result success(T object) {
        Result r = new Result();
        r.setMsg("操作成功！");
        r.object = object;
        r.setStateCode(200);
        return r;
    }
    public static <T> Result success(String msg,T object) {
        Result r = new Result();
        r.object = object;
        r.setMsg(msg);
        r.setStateCode(200);
        return r;
    }
    public static <T> Result error(String msg) {
        Result r = new Result();
        r.object = null;
        r.setMsg(msg);
        r.setStateCode(500);
        return r;
    }
}
